#include <fstream>
#include <string>
#include <math.h>
#include <iostream>
#include "Material.h"

namespace glow
{
  using namespace std;
  
  Material::Material()
  {
    Material_Ambient[0] = 0.0;
    Material_Ambient[1] = 0.0;
    Material_Ambient[2] = 0.0;
    Material_Ambient[3] = 0.0;

    Material_Diffuse[0] = 1.0;
    Material_Diffuse[1] = 1.0;
    Material_Diffuse[2] = 1.0;
    Material_Diffuse[3] = 1.0;

    Material_Specular[0] = 1.0;
    Material_Specular[1] = 1.0;
    Material_Specular[2] = 1.0;
    Material_Specular[3] = 1.0;

    _shininess = 1.0;
  }

  void Material::setAmbient(const Color4f &color)
  {
    Material_Ambient[0] = color.r;
    Material_Ambient[1] = color.g;
    Material_Ambient[2] = color.b;
    Material_Ambient[3] = color.a;
  }

  void Material::setDiffuse(const Color4f &color)
  {
 
    Material_Diffuse[0] = color.r;
    Material_Diffuse[1] = color.g;
    Material_Diffuse[2] = color.b;
    Material_Diffuse[3] = color.a;
  }

  void Material::setSpecular(const Color4f &color)
  {
    Material_Specular[0] = color.r;
    Material_Specular[1] = color.g;
    Material_Specular[2] = color.b;
    Material_Specular[3] = color.a;
  }

  void Material::setShininess(float shininess)
  {
    _shininess = shininess;
  }
  
  void Material::activate() const
  {  
    glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambient);
    glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Diffuse);
    glMaterialfv( GL_FRONT, GL_SPECULAR, Material_Specular);
    glMaterialf( GL_FRONT, GL_SHININESS, _shininess);
  }

}
